package com.test.demo.mydubbo.framework.protocol.dubbo.coder;

import com.alibaba.fastjson.JSON;
import com.test.demo.mydubbo.framework.protocol.DataFormater;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class DataFormaterEncoder extends MessageToByteEncoder<DataFormater> {
    protected void encode(ChannelHandlerContext channelHandlerContext, DataFormater dataFormater, ByteBuf byteBuf) throws Exception {
        String string = JSON.toJSONString(dataFormater);
        byteBuf.writeBytes(string.getBytes());
    }
}
